package bakaLevel;

import pluginMain.Configer;

public class PlayerLevelReader {
	private String strUserName;
	private int intCurrentExp = 0;
	private int intCurrentLevel = 1;
	private int intCurrentUnusedPoint = 2;
	private int intPointPower = 0;
	private int intPointAgility = 0;
	private int intPointInt = 0;
	private int intKillCount = 0;
	private int intDamageCountE = 0;
	private int intDamageCountP = 0;
	private int intPVPKillCount = 0;
	private int intNextLevelRequireExp;
	// Pre-Level gain 2 point
	private final String CONST_USER_LEVEL = ".Level";
	private final String CONST_USER_EXP = ".Exp";
	private final String CONST_USER_SKILLPOINT = ".UnusedPoint";
	private final String CONST_USER_POW = ".Power";
	private final String CONST_USER_AGI = ".Agility";
	private final String CONST_USER_INT = ".Intelligence";
	private final String CONST_USER_KILL_COUNT = ".KillCount";
	private final String CONST_USER_KILL_PLAYER_COUNT = ".PVPCount";
	private final String CONST_USER_DAMAGE_PLAYER = ".PVPDamage";
	private final String CONST_USER_DAMAGE_ENV = ".PVEDamage";
	private Configer cfgUserExp;

	public PlayerLevelReader(String UserName) {
		strUserName = UserName;
		cfgUserExp = BAKALevel.instance.getConfigInstance();
		intCurrentLevel = cfgUserExp.getInt(strUserName + CONST_USER_LEVEL);
		intCurrentExp = cfgUserExp.getInt(strUserName + CONST_USER_EXP);
		intCurrentUnusedPoint = cfgUserExp.getInt(strUserName + CONST_USER_SKILLPOINT);
		intNextLevelRequireExp = BAKALevel.instance.modelInstance.LevelRequireExp(intCurrentLevel + 1);
		intPointAgility = cfgUserExp.getInt(strUserName + CONST_USER_AGI);
		intPointInt = cfgUserExp.getInt(strUserName + CONST_USER_INT);
		intPointPower = cfgUserExp.getInt(strUserName + CONST_USER_POW);
		intKillCount = cfgUserExp.getInt(strUserName + CONST_USER_KILL_COUNT);
		intDamageCountE = cfgUserExp.getInt(strUserName + CONST_USER_DAMAGE_PLAYER);
		intDamageCountP = cfgUserExp.getInt(strUserName + CONST_USER_DAMAGE_ENV);
		intPVPKillCount = cfgUserExp.getInt(strUserName + CONST_USER_KILL_PLAYER_COUNT);
	}

	public int getCurrentLevel() {
		return intCurrentLevel;
	}

	public int getCurrentExp() {
		return intCurrentExp;
	}

	public void playerGainExp(int Exp) {
		intCurrentExp += Exp;
		if (intNextLevelRequireExp <= intCurrentExp) {
			intCurrentLevel++;
			intCurrentUnusedPoint += 2;
			// gain pre level point
		}
	}

	public int getAgility() {
		return intPointAgility;
	}

	public int getIntelligence() {
		return intPointInt;
	}

	public int getPower() {
		return intPointPower;
	}

	public boolean AddAgility() {
		if (intCurrentUnusedPoint > 1) {
			intPointAgility++;
			intCurrentUnusedPoint--;
			return true;
		} else {
			return false;
		}
	}

	public boolean AddIntelligent() {
		if (intCurrentUnusedPoint > 1) {
			intPointInt++;
			intCurrentUnusedPoint--;
			return true;
		} else {
			return false;
		}
	}

	public boolean AddPower() {
		if (intCurrentUnusedPoint > 1) {
			intPointPower++;
			intCurrentUnusedPoint--;
			return true;
		} else {
			return false;
		}
	}

	public void AddKillCount() {
		intKillCount++;
	}

	public int getPlayerKillMonsterCoun() {
		return intKillCount;
	}

	public void AddPVPKillCount() {
		intPVPKillCount++;
	}

	public int getPlayerPVPKillCount() {
		return intPVPKillCount;
	}

	public int getDamageToMonster() {
		return intDamageCountE;
	}

	public int getDamageToPlayer() {
		return intDamageCountP;
	}

	public void AddDamageToMonster(int Damage) {
		intDamageCountE += Damage;
	}

	public void AddDamageToPlayer(int Damage) {
		intDamageCountP += Damage;
	}
}
